import 'package:casdon/app/config/env/common_config.dart';
import 'package:json_annotation/json_annotation.dart';
part 'login_api.g.dart';

enum LoginGrantType { password, sms, email, social, phone }

enum LoginSource { appleid, wechat_open }

@JsonSerializable()
class RequestLogin {
  @JsonKey(includeIfNull: false)
  final String? userName;
  @JsonKey(includeIfNull: false)
  final String? password;
  @JsonKey(defaultValue: "app_user")
  final String userType;
  @JsonKey(includeIfNull: false)
  final String grantType;
  @JsonKey(includeIfNull: false)
  final String clientId;
  @JsonKey(includeIfNull: false)
  final String? source;
  @JsonKey(includeIfNull: false)
  final String? socialCode;
  @JsonKey(includeIfNull: false)
  final String? socialState;
  @JsonKey(includeIfNull: false)
  final String? token;
  @JsonKey(includeIfNull: false)
  final String? appleUser;
  @JsonKey(includeIfNull: false)
  final String? phonenumber;
  @JsonKey(includeIfNull: false)
  final String? smsCode;

  RequestLogin({
    this.userName,
    this.password,
    this.userType = "app_user",
    required this.grantType,
    String? clientId,
    this.source,
    this.socialCode,
    this.socialState,
    this.token,
    this.appleUser,
    this.phonenumber,
    this.smsCode,
  }) : clientId = clientId ?? CommonConfig.app_clientID;
  Map<String, dynamic> toJson() => _$RequestLoginToJson(this);
}

@JsonSerializable()
class ResponseLogin {
  final String access_token;
  final String client_id;

  ResponseLogin({required this.access_token, required this.client_id});

  factory ResponseLogin.fromJson(Map<String, dynamic> json) =>
      _$ResponseLoginFromJson(json);
}
